<template>
	<view class="notice_list">
		<scroll-view scroll-y="true" :style="{ height: scrollHeight-safeAreaHeight - 50 + 'px' }" class="list_content">
			<view v-for="(item,index) in list" :key="index" class="list_item" @click="toDetail(item)">
				<view class="item_sec">
				  <view class="item_sec_l">
				    <image v-if="item.imgUrl" class="img" :src="item.imgUrl" mode="scaleToFill" />
						<image v-else class="img" src="https://mp-fc704468-4c2b-49a0-9046-b3d5835c3804.cdn.bspapp.com/cloudstorage/nopic.png" mode="scaleToFill" />
				  </view>
				  <view class="item_sec_r">
				    <view class="title">{{ item.title }}</view>
				    <view class="publishTime">发布时间：{{ item.pubTime || '--' }}</view>  
				    <view class="tag">{{item.type}}</view>
				  </view>
				</view>
				<view class="item_foot">
				  <view class="looks">
				    <view class="count">作者：{{ item.author }}</view>
				  </view>
				</view>
			</view>
			<view class="empty">
				<u-empty mode="list" v-if="list.length==0"></u-empty>
			</view>
		</scroll-view>
		<view class="foot">
			<u-button throttleTime="1000" type="primary" shape="circle" color="#3585F7" text="新 增" @click="goAdd"></u-button>
		</view>
	</view>
</template>

<script>
	import { systemInfo } from "@/mixins/system.js";
	import { getStorageSync, navigateTo } from '@/static/utils';
	export default {
		data() {
			return {
				list:[]
			};
		},
		onLoad() {
			this.getList()
		},
		mixins: [systemInfo],
		methods:{
			goAdd(){
				navigateTo('docs/notice/addUpdateNotice',{type:'add'})
			},
			toDetail(item){
				navigateTo('docs/notice/addUpdateNotice',{type:'detail',id:item._id})
			},
			getList(){
				uni.request({
					url: https://fc-mp-fff067d4-0ad0-46f1-8940-3076faaf2173.next.bspapp.com/getNotice',
					data: {userId:getStorageSync('userInfo')._id},
					success: (res) => {
						console.log(res);
						if (res.data.code == 200) {
							this.list = res.data.data
						}else{
							this.list = []
							// uni.$u.toast(res.data.mesg)
						}
					}
				})
			}
		}
		
	}
</script>

<style lang="less" scoped>
.notice_list{
	width: 100vw;
	height: 100vh;
	background-color: #F8F8F8;
	.empty{
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.list_content{
		padding: 0 16rpx;
		box-sizing: border-box;
		.list_item{
			width:calc(100% - 20rpx);
			margin: 30rpx 10rpx;
			padding: 20rpx 14rpx 10rpx 14rpx;
			box-sizing: border-box;
			background: #fff;
			border-radius: 10rpx;
			box-shadow:0px 12px 8px -12px rgba(0,0,0,0.4);
			.item_sec{
			  width: 100%;
			  display: flex;
			  padding-bottom: 10rpx;
			  align-items: center;
			  .item_sec_l{
			    width: 190rpx;
			    height: 160rpx;
			    .img{
			      width: 100%;
			      height: 100%;
			  		border-radius: 10rpx;
			    }
			  }
			  .item_sec_r{
					height: 160rpx;
			    flex: 1;
			    padding-left: 10rpx;
			    box-sizing: border-box;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
			    .title{
			      font-size: 30rpx;
			      font-weight: 700;
			      margin: 2rpx 0;
						font-family: Microsoft YaHei;
						color: #333333;
			      display: -webkit-box;
			      -webkit-line-clamp:1;//属性值为几  代表的就是显示几行
			      overflow: hidden;
			      -webkit-box-orient:vertical;
			    }
					.publishTime{
						width: 100%;
						display: flex;
						align-items: center;
						font-size: 26rpx;
						color: #999999;
						padding: 20rpx 0 10rpx 0;
					}
			    .item_sec_r_flex{
			      width: 100%;
			      display: flex;
			      align-items: center;
						padding: 4rpx 0;
						font-size: 28rpx;
						font-family: Microsoft YaHei;
						font-weight: 400;
						color: #999999;
						.from{
							flex: 1;
						}
			    }
			    .tag{
						width: fit-content;
			      display: inline-block;
			      padding: 2rpx 18rpx;
			      background: #E5F7F0;
			      border-radius: 2rpx;
			      color: #29BD80;
			      font-size: 24rpx;
			      margin: 10rpx 0 0;
			    }
			  }
			}
			.item_foot{
			  width: 100%;
			  display: flex;
			  align-items: center;
				justify-content: space-between;
			  border-top: 1px solid #F5F5F5;
			  padding: 10rpx 0;
			  font-size: 26rpx;
			  .looks{
			    width: 50%;
			    display: flex;
			    align-items: center;
			    font-size: 26rpx;
			    font-family: Microsoft YaHei;
			    font-weight: 400;
			    color: #999999;
			    .count{
			      padding-left: 6rpx;
			    }
			  }
			}
		}
	}
	.foot{
		width: 100%;
		height: 50px;
		background: #fff;
		padding: 10rpx 20rpx;
		box-sizing: border-box;
	}
}
</style>
